package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.domain.GridMemberPerformanceRankingPojo;
import cn.com.yusys.yusp.admin.service.GridMemberPerformanceRankingService;
import cn.com.yusys.yusp.commons.excel.ExcelTaskManager;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/GridMemberPerformanceRankingResource")
public class GridMemberPerformanceRankingResource {

    @Resource
    GridMemberPerformanceRankingService gridMemberPerformanceRankingService;

    @Resource
    private ExcelTaskManager excelTaskManager;

    private String pojoClassName = GridMemberPerformanceRankingPojo.class.getName();
    private String exportSql = "getGridMemberPerformanceRankingInfo";

    @GetMapping("/getGridMemberPerformanceRankingInfo")
    public ResultDto<List<Map<String, Object>>> getGridMemberPerformanceRankingInfo(QueryModel queryModel) {
        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        List<Map<String, Object>> list = new ArrayList<>();
        list = gridMemberPerformanceRankingService.getGridMemberPerformanceRankingInfo(queryModel);
        return new ResultDto<>(list);
    }


    @GetMapping("/exportExcel")
    public ResultDto<String> exportExcel(QueryModel queryModel){
        CustCenterResource.judgeUserJurisdiction(queryModel, true);
        String taskId = excelTaskManager.addExcelExportTask(exportSql, null, queryModel, pojoClassName);
        return new ResultDto<>(taskId);
    }
}
